package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.EvaluateLike;
import com.nbsaas.boot.evaluate.api.domain.simple.EvaluateLikeSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 评价点赞-列表对象转换器
*/

public class EvaluateLikeSimpleConvert implements Converter<EvaluateLikeSimple, EvaluateLike> {




@Override
public EvaluateLikeSimple convert(EvaluateLike source) {
    EvaluateLikeSimple result = new EvaluateLikeSimple();

                result.setNote(source.getNote());
                result.setIpAddress(source.getIpAddress());
                if(source.getLikeType()!=null){
                   Map<Integer,String> LikeTypeMap=new HashMap<>();
                       LikeTypeMap.put(1,"有用");
                       LikeTypeMap.put(2,"无用");
                       LikeTypeMap.put(3,"点赞");
                       LikeTypeMap.put(4,"踩");
                   String label=  LikeTypeMap.get(source.getLikeType());
                   result.setLikeTypeName(label);
                }
                result.setLikeType(source.getLikeType());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setUserAgent(source.getUserAgent());
                result.setId(source.getId());

                try {
                    if(source.getUser()!=null){
                        result.setUserName(source.getUser().getName());
                    }
                } catch (Exception ignored) { }


               try {
                   if(source.getEvaluate()!=null){
                       result.setEvaluate(source.getEvaluate().getId());
                   }
                } catch (Exception ignored) { }


               try {
                   if(source.getUser()!=null){
                       result.setUser(source.getUser().getId());
                   }
                } catch (Exception ignored) { }

                result.setAddDate(source.getAddDate());
                result.setLastDate(source.getLastDate());


    return result;
}

}